home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Info / For Developers / Finder Flags Plugin / Finder Flags Sources / Finder Flags Postlinker / EvenMoreFiles.c next >
Encoding:
Text File  |  1999-06-19  |  2.7 KB  |  95 lines  |  [TEXT/CWIE]

  1. // EvenMoreFiles.c
  2. // Copyright © 1999 Polaschek Computing, Inc. All rights reserved.
  3. //
  4. // Insert comment here
  5. //
  6.  
  7. #include "EvenMoreFiles.h"
  8.  
  9. /*#ifdef __cplusplus
  10. #error "The C++ compiler should not be active"
  11. #endif*/
  12.  
  13. OSErr FSpGetFXInfo(const FSSpec* spec, FXInfo* xInfo)
  14. {
  15.     CInfoPBRec    infoRec = {0};
  16.     OSErr        err = noErr;
  17.  
  18.     infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name;    // cast away constness
  19.     infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
  20.     infoRec.hFileInfo.ioDirID = spec->parID;
  21.     err = PBGetCatInfoSync(&infoRec);
  22.     if (err == noErr) {
  23.         *xInfo = infoRec.hFileInfo.ioFlXFndrInfo;
  24.     }
  25.  
  26.     return err;
  27. }
  28.  
  29.  
  30. OSErr FSpSetFXInfo(const FSSpec* spec, FXInfo* xInfo)
  31. {
  32.     CInfoPBRec    infoRec = {0};
  33.     OSErr        err = noErr;
  34.  
  35.     infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name;
  36.     infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
  37.     infoRec.hFileInfo.ioDirID = spec->parID;
  38.     err = PBGetCatInfoSync(&infoRec);
  39.     if (err == noErr) {
  40.         // we have to restore ioDirID, since PBGetCatInfo changes it,
  41.         // and if I don't restore it, I try looking for the directory
  42.         // that has the id of the file index of the file, which isn't
  43.         // found, which causes a fnfErr. Sheesh.
  44.         infoRec.hFileInfo.ioDirID = spec->parID;
  45.         infoRec.hFileInfo.ioFlXFndrInfo = *xInfo;
  46.         err = PBSetCatInfoSync(&infoRec);
  47.     }
  48.  
  49.     return err;
  50. }
  51.  
  52.  
  53. OSErr FSpGetExtendedFileInfo(const FSSpec* spec, ExtendedFileInfo* xInfo)
  54. {
  55.     CInfoPBRec    infoRec = {0};
  56.     OSErr        err = noErr;
  57.  
  58.     infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name;    // cast away constness
  59.     infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
  60.     infoRec.hFileInfo.ioDirID = spec->parID;
  61.     err = PBGetCatInfoSync(&infoRec);
  62.     if (err == noErr) {
  63.         // I can't just copy. The structures are binary-compatible though
  64.         // (it says so in Finder.h), so I can just BlockMove the data over.
  65.         BlockMoveData(&infoRec.hFileInfo.ioFlXFndrInfo, xInfo, sizeof(ExtendedFileInfo));
  66.     }
  67.  
  68.     return err;
  69. }
  70.  
  71.  
  72. OSErr FSpSetExtendedFileInfo(const FSSpec* spec, ExtendedFileInfo* xInfo)
  73. {
  74.     CInfoPBRec    infoRec = {0};
  75.     OSErr        err = noErr;
  76.  
  77.     infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name;
  78.     infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
  79.     infoRec.hFileInfo.ioDirID = spec->parID;
  80.     err = PBGetCatInfoSync(&infoRec);
  81.     if (err == noErr) {
  82.         // I can't just copy. The structures are binary-compatible though
  83.         // (it says so in Finder.h), so I can just BlockMove the data over.
  84.         BlockMoveData(xInfo, &infoRec.hFileInfo.ioFlXFndrInfo, sizeof(ExtendedFileInfo));
  85.         // we have to restore ioDirID, since PBGetCatInfo changes it,
  86.         // and if I don't restore it, I try looking for the directory
  87.         // that has the id of the file index of the file, which isn't
  88.         // found, which causes a fnfErr. Sheesh.
  89.         infoRec.hFileInfo.ioDirID = spec->parID;
  90.         err = PBSetCatInfoSync(&infoRec);
  91.     }
  92.  
  93.     return err;
  94. }
  95.